package com.itfenghuang.day15;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/*
接收客户端的消息并回送消息
 */
public class A03_Server {
    public static void main(String[] args) throws IOException {
//        创建ServerSocket对象
        ServerSocket ss = new ServerSocket(12233);
//        监听连接
        Socket at = ss.accept();
//        获取输入流
        InputStream is = at.getInputStream();
//        读取数据
        byte[] bys = new byte[1024];
        int len = is.read(bys);
        System.out.println(new String(bys,0,len));
//        获取输出流
        OutputStream os = at.getOutputStream();
        os.write("僵小鱼是僵尸".getBytes());
        ss.close();
    }
}
